package com.java1412;

import brave.sampler.Sampler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author java1412
 * @since 2023-07-21 11:51:42
 */
@SpringBootApplication
@RestController
public class ServiceZipkinApplication {
    public static void main(String[] args) {
        SpringApplication.run(ServiceZipkinApplication.class, args);
    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Resource
    private RestTemplate restTemplate;

    @RequestMapping(value = "/hi")
    public String callHome() {
        return restTemplate.getForObject("http://localhost:8989/miya", String.class);
    }

    @RequestMapping(value = "/info")
    public String info() {
        return "I'm service-hi";
    }

    // 注册采样器
    @Bean
    public Sampler sampler() {
        return Sampler.ALWAYS_SAMPLE;
    }
}
